package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.market.entity.PromotionPresellRule;
import com.jic.market.mapper.PromotionPresellRuleMapper;
import com.jic.market.service.PromotionPresellRuleService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 预售限制规则表
 * @author : 
 * @email : 
 * @since : 2020-03-06 11:11:21
 * @version : v1.0.0
 */
@Service
public class PromotionPresellRuleServiceImpl implements PromotionPresellRuleService{

    @Autowired
    private PromotionPresellRuleMapper promotionPresellRuleMapper;

    @Override
    public long insert(PromotionPresellRule promotionPresellRule) {
        long flag = promotionPresellRuleMapper.insert(promotionPresellRule);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return promotionPresellRuleMapper.delete(id);
    }

    @Override
    public long update(PromotionPresellRule promotionPresellRule) {
        return promotionPresellRuleMapper.update(promotionPresellRule);
    }

    @Override
    public PromotionPresellRule queryByPrimaryKey(Long id){
        return promotionPresellRuleMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<PromotionPresellRule> query(PromotionPresellRule promotionPresellRule){
        return promotionPresellRuleMapper.query(promotionPresellRule);
    }

    @Override
    public PageResult<PromotionPresellRule> queryPage(PromotionPresellRule promotionPresellRule, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<PromotionPresellRule> list = promotionPresellRuleMapper.queryPage(startIndex, pageQuery.getLimit(), promotionPresellRule);
        long count = promotionPresellRuleMapper.queryPageCount(promotionPresellRule);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}